package com.suray.wcs.service.enums;

public enum ExecuteDevice {
    /**
     * 基站
     */
    JIZHAN(0, "基站"),
    /**
     * plc
     */
    PLC(1, "PLC"),
    /**
     * 扫码设备
     */
    SCAN(2, "扫码"),
    /**
     * 称重
     */
    WEIGHT(3, "称重");

    private int deviceType;
    private String description;

    ExecuteDevice(int deviceType, String description) {
        this.deviceType = deviceType;
        this.description = description;
    }

    @Override
    public String toString() {
        return description;
    }

    public static ExecuteDevice parseTaskType(int deviceType) {
        ExecuteDevice[] taskTypes = ExecuteDevice.values();
        for (ExecuteDevice type : taskTypes) {
            if (type.deviceType == deviceType) {
                return type;
            }
        }
        throw new IllegalArgumentException("任务类型参数错误:" + deviceType);
    }

    public static ExecuteDevice parseTaskType(String description) {
        ExecuteDevice[] taskTypes = ExecuteDevice.values();
        for (ExecuteDevice type : taskTypes) {
            if (type.description.equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("任务类型描述错误:" + description);
    }

    public int getTypeNum() {

        return deviceType;
    }

}
